<template>
    <div>
         <!-- 面包屑导航 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>订单管理</el-breadcrumb-item>
            <el-breadcrumb-item>订单列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-row>
                <el-input placeholder="请输入内容" class="input-with-select" style="width:300px">
                    <el-button slot="append" icon="el-icon-search"></el-button>
                </el-input>
            </el-row>
            <el-table :data="orderList">
                <el-table-column type="index"></el-table-column>
                <el-table-column prop="order_number" label="订单编号"></el-table-column>
                <el-table-column prop="order_price" label="订单价格"></el-table-column>
                <el-table-column prop="order_pay" label="是否付款">
                    <template slot-scope="scope">
                        <el-tag  v-if="scope.row.order_pay==='1'" type="success">已付款</el-tag>
                        <el-tag v-else type="danger">未付款</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="is_send" label="是否发货">
                    <template slot-scope="scope">
                       {{scope.row.is_send}}
                    </template>
                </el-table-column>
                <el-table-column prop="create_time" label="下单时间">
                    <template slot-scope="scope">
                        {{scope.row.create_time|timeHandle}}
                    </template></el-table-column>
                <el-table-column prop="order_number" label="操作">
                     <template >
                        <el-button size="mini" type="primary" icon="el-icon-edit"></el-button>
                        <el-button size="mini" type="warning" icon="el-icon-star-off"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 分页部分 -->
             <!-- <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="1"
                :page-sizes="[100, 200, 300, 400]"
                :page-size="100"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
             </el-pagination> -->
             <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryInfo.page"
                :page-sizes="[1, 5, 10, 15]"
                :page-size="queryInfo.pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
export default {
  data () {
    return {
      queryInfo: {
        pagenum: 1,
        pagesize: 5
      },
      orderList: [],
      total: 0
    }
  },
  created () {
    this.getOrderList()
  },
  methods: {
    async getOrderList () {
      const { data: res } = await this.$http.get('orders', { params: this.queryInfo })
      if (res.meta.status !== 200) {
        return this.$Message.error('请求订单列表失败')
      }
      this.orderList = res.data.goods
      this.total = res.data.total
      console.log(this.total)
    },
    // 分页大小发生改变
    handleSizeChange (val) {
      this.queryInfo.pagesize = val
      console.log(this.queryInfo)
      this.getOrderList()
    },
    // 当前页发生变化
    handleCurrentChange (val) {
      this.queryInfo.pagenum = val
      this.getOrderList()
    }
  }
}
</script>

<style lang="less" scoped>

</style>
